<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-type" content="text/html; charset=utf-8">
		<title>Data-bound Form element Kitchen Sink test</title>
		<style type="text/css">
			@import "css/app-format.css";
			@import "../../../../dijit/themes/claro/claro.css";
			label {
				text-align: left;
				width: 100%;
			}
		</style>
		<script type="text/javascript" djConfig="parseOnLoad:1,isDebug:1,async:1" src="../../../../dojo/dojo.js"></script>
		<script type="text/javascript">

		var store, selmodel, decselmodel, numspinmodel; 
		var store2, filmodel, decfilmodel;
		var combomodel, deccombomodel;
		var datemodel, decdatemodel; 
		var slidermodel, decslidermodel;
		var numspinmodel, decnumspinmodel;
		var simpTAmodel, decsimpTAmodel;
		var textareamodel, dectextareamodel;
		var deccalmodel, deccolormodel;

		require([
			'dojo/_base/kernel',
			'dojo/parser',
			'dojo/ready',
			'dojox/mvc',
			'dijit/form/TextBox',
			'dijit/form/Button',
			'dijit/form/Select',
			'dijit/form/FilteringSelect',
			'dijit/form/ComboBox',
			'dijit/form/DateTextBox',
			'dijit/form/HorizontalSlider',
			'dijit/form/NumberSpinner',
			'dijit/form/SimpleTextarea',
			'dijit/form/Textarea',
			'dojo/data/ItemFileReadStore',
			'dijit/Calendar',
			'dijit/ColorPalette',
			'dojox/mvc/Group',
			'dojox/mvc/Output',
			'dojo/date/locale'
			], function(dojo, parser, ready, mvc, TextBox, Button, Select, FilteringSelect, ComboBox, DateTextBox, HorizontalSlider, NumberSpinner,
						SimpleTextarea, Textarea, ItemFileReadStore, Calendar, ColorPalette){

			var alreadyset = false;	
			var data = [
				{id: '1',name:"one"},
				{id: '2',name:"two"},
				{id: '3',name:"three"},
				{id: '4',name:"four"},
				{id: '5',name:"five"},
				{id: '6',name:"six"},
				{id: '7',name:"seven"},
				{id: '8',name:"eight"},
				{id: '9',name:"nine"},
				{id: '10',name:"ten"},
				{id: '11',name:"eleven"},
				{id: '12',name:"twelve"},
				{id: '13',name:"thirteen"}
			  ];
			store = new ItemFileReadStore({
				data: {
					identifier: 'id',
					label: 'name',
					items: data
				}
			});

			var data2 = {
				identifier: "value",
				label: "label",
				items: [
					{value: "1", label: "one"},
					{value: "2", label: "two"},
					{value: "3", label: "three"},
					{value: "4", label: "four"},
					{value: "5", label: "five"},
					{value: "6", label: "six"},
					{value: "7", label: "seven"},
					{value: "8", label: "eigth"},
					{value: "9", label: "nine"},
					{value: "10", label: "ten"},
					{value: "11", label: "eleven"},
					{value: "12", label: "twelve"},
					{value: "13", label: "thirteen"},
					{value: "14", label: "fourteen"}
				]
			};
			store2 = new ItemFileReadStore({data:dojo.clone(data2)});

			// create models for selects
			selmodel = new mvc.newStatefulModel({data: {number: '1'}});
			decselmodel = new mvc.newStatefulModel({data: {number: '1'}});

			// create models for filtering selects
			filmodel = new mvc.newStatefulModel({data: {number: '2'}});
			decfilmodel = new mvc.newStatefulModel({data: {number: '2'}});

			// create models for ComboBoxes
			combomodel = new mvc.newStatefulModel({data: {number: 'three'}});
			deccombomodel = new mvc.newStatefulModel({data: {number: 'three'}});

			// create a model for DateTextBox
			datemodel = new mvc.newStatefulModel({data: {number: "2011-04-04"}});
			decdatemodel = new mvc.newStatefulModel({data: {number: "2011-04-04"}});

			// create a model for Slider
			slidermodel = new mvc.newStatefulModel({data: {number: '5'}});
			decslidermodel = new mvc.newStatefulModel({data: {number: '5'}});

			// create a model for NumberSpinner
			numspinmodel = new mvc.newStatefulModel({data: {number: '6'}});
			decnumspinmodel = new mvc.newStatefulModel({data: {number: '6'}});

			// create a model for SimpleTextArea
			simpTAmodel = new mvc.newStatefulModel({data: {number: '7'}});
			decsimpTAmodel = new mvc.newStatefulModel({data: {number: '7'}});

			// create a model for TextArea
			textareamodel = new mvc.newStatefulModel({data: {number: '8'}});
			dectextareamodel = new mvc.newStatefulModel({data: {number: '8'}});

			// create a model for dijit.Calendar
			deccalmodel = new mvc.newStatefulModel({data: {date: "Mon Apr 04 2011 01:00:00 GMT-0400 (Eastern Daylight Time)"}});

			// create a model for dijit.ColorPalette
			deccolormodel = new mvc.newStatefulModel({data: {code: "#000000"}});

			// Handle the programmatic creation of widgets here:
			
			// create the select, textbox, output and button			
			var sel = new Select({
				store: store,
				loadChildrenOnOpen: true,
			//	value: 1,	
				ref: selmodel.number // bind to model.number
			}, document.getElementById('sel'));
			
			var text = new TextBox({
				//id: "seltext",
				ref: selmodel.number
			}, document.getElementById('seltext'));			
			text.startup();
			
			var selOutput = new mvc.Output({
				ref: selmodel.number
			}, document.getElementById('selOutput'));
			selOutput.startup();

			var reset1 = new Button({
				onClick: function(){selmodel.reset();},
				id: "selReset",
				label: "Reset"
			}, document.getElementById('reset1'));
			reset1.startup();


			sel.watch('value', function () {
				//console.log('sel value changed', arguments);
			});

			text.watch('value', function () {
				//console.log('text value changed', arguments);
			});
			
			sel.startup();
			

			// create the filtering select, textbox, output and button			
			var filsel = new FilteringSelect({
				store: store,
				ref: filmodel.number // bind to model.number
			}, document.getElementById('filsel'));
			
			var filtext = new TextBox({
				ref: filmodel.number
			}, document.getElementById('filtext'));
			
			var filoutput = new mvc.Output({
				ref: filmodel.number
			}, document.getElementById('filoutput'));			
			filoutput.startup();

			var filreset = new Button({
				onClick: function(){filmodel.reset();},
				id: "filReset",
				label: "Reset"
			}, document.getElementById('filreset'));
			filreset.startup();
			
			filtext.startup();
			filsel.startup();
			
			// create the comboBox, textbox, output and button			
			var combo = new ComboBox({
				store: store,
				ref: combomodel.number // bind to model.number
			}, document.getElementById('combosel'));
			
			var combotext = new TextBox({
				ref: combomodel.number
			}, document.getElementById('combotext'));
			
			var combooutput = new mvc.Output({
				ref: combomodel.number
			}, document.getElementById('combooutput'));			
			combooutput.startup();

			var comboreset = new Button({
				onClick: function(){combomodel.reset();},
				id: "comboReset",
				label: "Reset"
			}, document.getElementById('comboreset'));
			comboreset.startup();
			
			combotext.startup();
			combo.startup();
			
			// create the dijit.form.DateTextBox, textbox, output and button			
			var dateWid = new DateTextBox({
				ref: datemodel.number // bind to model.number
			}, document.getElementById('datesel'));
			
			var datetext = new TextBox({
				ref: datemodel.number
			}, document.getElementById('datetext'));
			
			var dateoutput = new mvc.Output({
				ref: datemodel.number
			}, document.getElementById('dateoutput'));			
			dateoutput.startup();

			var datereset = new Button({
				onClick: function(){datemodel.reset();},
				id: "dateReset",
				label: "Reset"
			}, document.getElementById('datereset'));
			datereset.startup();
			
			datetext.startup();
			dateWid.startup();
			
			// create the dijit.form.HorizontalSlider, textbox, output and button			
			var sliderWid = new HorizontalSlider({
						style:{width:"190px"},
						minimum:0,
						maximum:100,
						discreteValues:21,
				ref: slidermodel.number // bind to model.number
			}, document.getElementById('slidersel'));
			
			var slidertext = new TextBox({
				ref: slidermodel.number
			}, document.getElementById('slidertext'));
			
			var slideroutput = new mvc.Output({
				ref: slidermodel.number
			}, document.getElementById('slideroutput'));			
			slideroutput.startup();

			var sliderreset = new Button({
				onClick: function(){slidermodel.reset();},
				id: "sliderReset",
				label: "Reset"
			}, document.getElementById('sliderreset'));
			sliderreset.startup();
			
			slidertext.startup();
			sliderWid.startup();
			
			// create the dijit.form.NumberSpinner, textbox, output and button			
			var numspinWid = new NumberSpinner({
			//	constraints:{max:100,places:0},
				ref: numspinmodel.number // bind to model.number
			}, document.getElementById('numspinsel'));
			
			var numspintext = new TextBox({
				ref: numspinmodel.number
			}, document.getElementById('numspintext'));
			
			var numspinoutput = new mvc.Output({
				ref: numspinmodel.number
			}, document.getElementById('numspinoutput'));			
			numspinoutput.startup();

			var numspinreset = new Button({
				onClick: function(){numspinmodel.reset();},
				id: "numspinReset",
				label: "Reset"
			}, document.getElementById('numspinreset'));
			numspinreset.startup();
			
			numspintext.startup();
			numspinWid.startup();
			
			// create the dijit.form.SimpleTextarea, textbox, output and button 			
			var simpTAWid = new SimpleTextarea({
				style:{height:"20px", width:"180px"},
				ref: simpTAmodel.number // bind to model.number
			}, document.getElementById('simpTAsel'));
			
			var simpTAtext = new TextBox({
				ref: simpTAmodel.number
			}, document.getElementById('simpTAtext'));
			
			var simpTAoutput = new mvc.Output({
				ref: simpTAmodel.number
			}, document.getElementById('simpTAoutput'));			
			simpTAoutput.startup();

			var simpTAreset = new Button({
				onClick: function(){simpTAmodel.reset();},
				id: "simpTAReset",
				label: "Reset"
			}, document.getElementById('simpTAreset'));
			simpTAreset.startup();
			
			simpTAtext.startup();
			simpTAWid.startup();

			// create the dijit.form.Textarea, textbox, output and button 
			var textareaWid = new Textarea({
			//	constraints:{max:100,places:0},
				ref: textareamodel.number // bind to model.number
			}, document.getElementById('textareasel'));
			
			var textareatext = new TextBox({
				ref: textareamodel.number
			}, document.getElementById('textareatext'));
			
			var textareaoutput = new mvc.Output({
				ref: textareamodel.number
			}, document.getElementById('textareaoutput'));			
			textareaoutput.startup();

			var textareareset = new Button({
				onClick: function(){textareamodel.reset();},
				id: "textareaReset",
				label: "Reset"
			}, document.getElementById('textareareset'));
			textareareset.startup();
			
			textareatext.startup();
			textareaWid.startup();

			});

		</script>
	</head>
	<body class="claro">
		<div id="wrapper">
			<div id="header" style="margin-top: 0px;">
				<div id="navigation"  style="margin-top: 0px;"></div>
				<div id="headerInsert"  style="margin-top: 0px;">
					<h2>Data-bound Form Element Kitchen Sink MVC test</h2>
				</div>
			</div>
			<div id="main" style="margin-top: 0px;">
				<div id="leftNav"></div>
				<div id="mainContent">
	
					<h2 style="margin-top: 0px;">Programmatic creation of Form elements:</h2>
					<table>
						<tbody>
							<tr>
								<td><label>Widget</label></td>
								<td><label></label></td>
								<td><label>Textbox</label></td>
								<td><label>Output</label></td>
								<td><label>Model Reset</label></td>
							</tr>
							<tr>
								<td><label for="sel">Select:</label></td>
								<td><div id="sel"></div></td>
								<td><div id="seltext"></div></td>
								<td><div id="selOutput"></div></td>
								<td><div id="reset1" ></div></td>
							</tr>
							<tr>
								<td><label for="filsel">FilteringSelect:</label></td>
								<td><div id="filsel"></div></td>
								<td><div id="filtext"></div></td>
								<td><div id="filoutput"></div></td>
								<td><div id="filreset"></div></td>
							</tr>
							<tr>
								<td><label for="combosel">ComboBox:</label></td>
								<td><div id="combosel"></div></td>
								<td><div id="combotext"></div></td>
								<td><div id="combooutput"></div></td>
								<td><div id="comboreset"></div></td>
							</tr>
							<tr>
								<td><label for="datesel">DateTextBox:</label></td>
								<td><div id="datesel"></div></td>
								<td><div id="datetext"></div></td>
								<td><div id="dateoutput"></div></td>
								<td><div id="datereset"></div></td>
							</tr>
							<tr>
								<td><label for="slidersel">Slider:</label></td>
								<td><div id="slidersel"></div></td>
								<td><div id="slidertext"></div></td>
								<td><div id="slideroutput"></div></td>
								<td><div id="sliderreset"></div></td>
							</tr>
							<tr>
								<td><label for="numspinsel">NumberSpinner:</label></td>
								<td><div id="numspinsel"></div></td>
								<td><div id="numspintext"></div></td>
								<td><div id="numspinoutput"></div></td>
								<td><div id="numspinreset"></div></td>
							</tr>
							<tr>
								<td><label for="simpTAsel">SimpleTextArea:</label></td>
								<td><div id="simpTAsel"></div></td>
								<td><div id="simpTAtext"></div></td>
								<td><div id="simpTAoutput"></div></td>
								<td><div id="simpTAreset"></div></td>
							</tr>
							<tr>
								<td><label for="textareasel">TextArea:</label></td>
								<td><div id="textareasel"></div></td>
								<td><div id="textareatext"></div></td>
								<td><div id="textareaoutput"></div></td>
								<td><div id="textareareset"></div></td>
							</tr>
						</tbody>
					</table>
	  
					<h2>Declarative creation of Form elements:</h2>
					<table>
						<tbody>
							<tr>
								<td><label>Widget</label></td>
								<td><label></label></td>
								<td><label>Textbox</label></td>
								<td><label>Output</label></td>
								<td><label>Model Reset</label></td>
							</tr>
							<tr>
							<!--  <td><label for="decsel">Select:</label></td>
								<td>
									<select id="decsel" style="width: 188px;" 
													data-dojo-id="decsel" data-dojo-type="dijit.form.Select" 
													data-dojo-props='name:"decsel",loadChildrenOnOpen: true, ref: decselmodel.number '>
										<option value="1">one</option>
										<option value="2">two</option>
										<option value="3">three</option>
										<option value="4">four</option>
									</select>
								</td>
							-->	
								<td><label for="decsel">Select:</label></td>
								<td>
									<select id="decsel" style="width: 188px;" 
													data-dojo-id="decsel" data-dojo-type="dijit.form.Select" 
													data-dojo-props='store:store, name:"decsel",loadChildrenOnOpen: true, ref: decselmodel.number '>
									</select>
								</td>
								<td>
									<input class="cell" id="decseltext" data-dojo-type="dijit.form.TextBox"
									data-dojo-props="ref: decselmodel.number"></input>
								</td>
								<td><span   id="decselOutput" data-dojo-type="dojox.mvc.Output"
											data-dojo-props="ref: decselmodel.number">
						 			${this.value}
								</span></td>
								<td><button id="decselReset" type="button" data-dojo-type="dijit.form.Button" 
											data-dojo-props="onClick: function(){decselmodel.reset();}">Reset</button></td>
							</tr>
							<tr>
								<td><label for="decfilsel">FilteringSelect:</label></td>
								<td>
									<input id="decfilsel" data-dojo-type="dijit.form.FilteringSelect"
										data-dojo-props='store:store, ref: decfilmodel.number'/>
								</td>
								<td>
									<input id="decfiltext" data-dojo-type="dijit.form.TextBox"
									data-dojo-props="ref: decfilmodel.number"></input>
								</td>
								<td><span id="decfilOutput" data-dojo-type="dojox.mvc.Output" 
											data-dojo-props="ref: decfilmodel.number">
						 			${this.value}
								</span></td>
								<td><button id="decfilReset" type="button" data-dojo-type="dijit.form.Button" 
											data-dojo-props="onClick: function(){decfilmodel.reset();}">Reset</button></td>
							</tr>
							<tr>
								<td><label for="deccombosel">ComboBox:</label></td>
								<td>
									<input id="deccombosel" data-dojo-type="dijit.form.ComboBox"
										data-dojo-props='store:store, ref: deccombomodel.number'/>
								</td>
								<td>
									<input id="deccombotext" data-dojo-type="dijit.form.TextBox"
									data-dojo-props="ref: deccombomodel.number"></input>
								</td>
								<td><span id="deccomboOutput" data-dojo-type="dojox.mvc.Output" 
											data-dojo-props="ref: deccombomodel.number">
						 			${this.value}
								</span></td>
								<td><button id="deccomboReset" type="button" data-dojo-type="dijit.form.Button" 
											data-dojo-props="onClick: function(){deccombomodel.reset();}">Reset</button></td>
							</tr>
							<tr>
								<td><label for="datesel">DateTextBox:</label></td>
								<td>
									<input id="decdatesel" data-dojo-type="dijit.form.DateTextBox"
										data-dojo-props='store:store, ref: decdatemodel.number'/>
								</td>
								<td>
									<input id="decdatetext" data-dojo-type="dijit.form.TextBox"
									data-dojo-props="ref: decdatemodel.number"></input>
								</td>
								<td><span id="decdateOutput" data-dojo-type="dojox.mvc.Output" 
											data-dojo-props="ref: decdatemodel.number">
						 			${this.value}
								</span></td>
								<td><button id="decdateReset" type="button" data-dojo-type="dijit.form.Button" 
											data-dojo-props="onClick: function(){decdatemodel.reset();}">Reset</button></td>
							</tr>
							<tr>
								<td><label for="decslidersel">Slider:</label></td>
								<td>
									<input id="decslidersel" data-dojo-type="dijit.form.HorizontalSlider"
										data-dojo-props='store:store, ref: decslidermodel.number,
														style:{width:"190px"}, minimum:0, maximum:100, discreteValues:21'/>
								</td>
								<td>
									<input id="decslidertext" data-dojo-type="dijit.form.TextBox"
									data-dojo-props="ref: decslidermodel.number"></input>
								</td>
								<td><span id="decsliderOutput" data-dojo-type="dojox.mvc.Output" 
											data-dojo-props="ref: decslidermodel.number">
						 			${this.value}
								</span></td>
								<td><button id="decsliderReset" type="button" data-dojo-type="dijit.form.Button" 
											data-dojo-props="onClick: function(){decslidermodel.reset();}">Reset</button></td>
							</tr>
							<tr>
								<td><label for="decnumspinsel">NumberSpinner:</label></td>
								<td>
									<input id="decnumspinsel" data-dojo-type="dijit.form.NumberSpinner"
										data-dojo-props='store:store, ref: decnumspinmodel.number'/>
								</td>
								<td>
									<input id="decnumspintext" data-dojo-type="dijit.form.TextBox"
									data-dojo-props="ref: decnumspinmodel.number"></input>
								</td>
								<td><span id="decnumspinOutput" data-dojo-type="dojox.mvc.Output" 
											data-dojo-props="ref: decnumspinmodel.number">
						 			${this.value}
								</span></td>
								<td><button id="decnumspinReset" type="button" data-dojo-type="dijit.form.Button" 
											data-dojo-props="onClick: function(){decnumspinmodel.reset();}">Reset</button></td>
							</tr>
							<tr>
								<td><label for="decsimpTAsel">SimpleTextArea:</label></td>
								<td>
									<input id="decsimpTAsel" data-dojo-type="dijit.form.Textarea"
										data-dojo-props='store:store, ref: decsimpTAmodel.number'/>
								</td>
								<td>
									<input id="decsimpTAtext" data-dojo-type="dijit.form.TextBox"
									data-dojo-props="ref: decsimpTAmodel.number"/>
								</td>
								<td><span id="decsimpTAOutput" data-dojo-type="dojox.mvc.Output" 
											data-dojo-props="ref: decsimpTAmodel.number">
						 			${this.value}
								</span></td>
								<td><button id="decsimpTAReset" type="button" data-dojo-type="dijit.form.Button" 
										data-dojo-props="onClick: function(){decsimpTAmodel.reset();}">Reset</button></td>
							</tr>
							<tr>
								<td><label for="dectextareasel">TextArea:</label></td>
								<td>
									<input id="dectextareasel" data-dojo-type="dijit.form.Textarea"
										data-dojo-props='store:store, ref: dectextareamodel.number'/>
								</td>
								<td>
									<input id="dectextareatext" data-dojo-type="dijit.form.TextBox"
									data-dojo-props="ref: dectextareamodel.number"/>
								</td>
								<td><span id="dectextareaOutput" data-dojo-type="dojox.mvc.Output" 
											data-dojo-props="ref: dectextareamodel.number">
						 			${this.value}
								</span></td>
								<td><button id="dectextareaReset" type="button" data-dojo-type="dijit.form.Button" 
										data-dojo-props="onClick: function(){dectextareamodel.reset();}">Reset</button></td>
							</tr>
						</tbody>
					</table>
	  
					<h2>Test data-bound dijit.Calendar:</h2>
					<table>
						<tbody>
							<tr>
								<td><label>Widget</label></td>
								<td><label></label></td>
								<td><label>Textbox</label></td>
								<td><label>Output</label></td>
								<td><label>Model Reset</label></td>
							</tr>
							<tr>
								<td><label for="deccal">Calendar:</label></td>
								<td>
									<input class="cell"  id="deccal" data-dojo-id="deccal"  data-dojo-type="dijit.Calendar" 
											data-dojo-props='ref: deccalmodel.date '/>
								</td>
								<td>
									<input class="cell" id="deccaltext" data-dojo-type="dijit.form.TextBox"
									data-dojo-props="ref: deccalmodel.date"></input>
								</td>
								<td><span   id="deccalOutput" data-dojo-type="dojox.mvc.Output"
											data-dojo-props="ref: deccalmodel.date">
						 			${this.value}
								</span></td>
								<td><button id="deccalReset" type="button" data-dojo-type="dijit.form.Button" 
											data-dojo-props="onClick: function(){deccalmodel.date.set('value', 'Mon Apr 04 2011 01:00:00 GMT-0400 (Eastern Daylight Time)')/*deccalmodel.reset();*/}">Reset</button></td>
							</tr>
							<tr>
								<td><label for="deccolor">ColorPalette:</label></td>
								<td>
									<div id="deccolor" data-dojo-type="dijit.ColorPalette" 
											data-dojo-props='palette:"3x4", ref: deccolormodel.code'></div>								
								</td>
								<td>
									<input class="cell" id="deccolortext" data-dojo-type="dijit.form.TextBox"
									data-dojo-props="ref: deccolormodel.code"></input>
								</td>
								<td><span   id="deccolorOutput" data-dojo-type="dojox.mvc.Output"
											data-dojo-props="ref: deccolormodel.code">
						 			${this.value}
								</span></td>
								<td><button id="deccolorReset" type="button" data-dojo-type="dijit.form.Button" 
											data-dojo-props="onClick: function(){deccolormodel.reset();}">Reset</button></td>
							</tr>
						</tbody>
					</table>
				</div>
			</div>
		</div>
	</body>
</html>
